using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chapter5CustomControlsCS
{
    [ToolboxData("<{0}:FirstSample runat=server></{0}:FirstSample>")]
    public class FirstSample : System.Web.UI.WebControls.WebParts.WebPart
    {
        string _BookTitle;
        protected override void CreateChildControls()
        {
            System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
            System.Web.UI.WebControls.Label lblBook = new System.Web.UI.WebControls.Label();

            System.Web.UI.WebControls.Table tbl = new System.Web.UI.WebControls.Table();
            System.Web.UI.WebControls.TableCell[] tc = new System.Web.UI.WebControls.TableCell[2];
            System.Web.UI.WebControls.TableRow[] tr = new System.Web.UI.WebControls.TableRow[2];

            tc[0] = new System.Web.UI.WebControls.TableCell();
            tc[1] = new System.Web.UI.WebControls.TableCell();
            tr[0] = new System.Web.UI.WebControls.TableRow();
            tr[1] = new System.Web.UI.WebControls.TableRow();
            tr[0].Cells.Add(tc[0]);
            tr[1].Cells.Add(tc[1]);
            tbl.Rows.Add(tr[0]);
            tbl.Rows.Add(tr[1]);

            lbl.Text = "Title:";
            lblBook.Text = _BookTitle;
            lblBook.Font.Bold = true;
            lblBook.BorderColor = System.Drawing.Color.Black;
            lblBook.BorderStyle = System.Web.UI.WebControls.BorderStyle.Solid;
            lblBook.BorderWidth = 1;

            tc[0].Controls.Add(lbl);
            tc[1].Controls.Add(lblBook);

            this.Controls.Add(tbl);
        }

        [System.Web.UI.WebControls.WebParts.WebBrowsable(true)]
        public string BookTitle
        {
            get 
            {
                return _BookTitle;
            }
            set 
            {
                _BookTitle = value;
            }
        }
    }
}
     
     